//
//  main.cpp
//  Scoring
//
//  Created by ryu on 2021/10/15.
//

//有5名选手：选手ABCDE，10个评委分别对每一名选手打分，去除最高分，去除评委中最低分，取平均分。

#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>

using namespace std;


void showInfo(vector<deque<int>> &v){
    for(int i = 0; i < v.size();i++){
        for(int j = 0;j < 10;j++){
            cout<<v[i][j]<<" ";
        }
        cout<<"\n";
    }
}

int calc(deque<int> &deq){
    sort(deq.begin(),deq.end());
    deq.pop_front();
    deq.pop_back();
    int sum = 0;
    for(int i = 0;i < deq.size();i++){
        sum += deq[i];
    }
    sum = sum/deq.size();
    cout<<sum<<endl;
    return sum;
}


int main(int argc, const char * argv[]) {
    // insert code here...
    
    srand((int)time(0));  // 产生随机种子  把0换成NULL也行
    
    vector<deque<int>> v;
    for(int i = 0;i < 5;i++){
        deque<int> deq;
        for(int j = 0;j < 10;j++){
            int tmp = rand() % 101;
            deq.push_back(tmp);
        }
        v.push_back(deq);
    }
    showInfo(v);
//    vector<deque<int>>::iterator it = v.begin();
//    while(it != v.end()){
//        calc(*it);
//    }
    for(int i = 0;i < 5;i++){
        calc(v[i]);
    }
    
    return 0;
}
